// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Requests;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using Elastic.Transport;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement;

public sealed partial class PutIndexTemplateRequestParameters : RequestParameters
{
	/// <summary>
	/// <para>User defined reason for creating/updating the index template</para>
	/// </summary>
	public string? Cause { get => Q<string?>("cause"); set => Q("cause", value); }

	/// <summary>
	/// <para>If `true`, this request cannot replace or update existing index templates.</para>
	/// </summary>
	public bool? Create { get => Q<bool?>("create"); set => Q("create", value); }

	/// <summary>
	/// <para>Period to wait for a connection to the master node.<br/>If no response is received before the timeout expires, the request fails and returns an error.</para>
	/// </summary>
	public Elastic.Clients.Elasticsearch.Serverless.Duration? MasterTimeout { get => Q<Elastic.Clients.Elasticsearch.Serverless.Duration?>("master_timeout"); set => Q("master_timeout", value); }
}

/// <summary>
/// <para>Creates or updates an index template.<br/>Index templates define settings, mappings, and aliases that can be applied automatically to new indices.</para>
/// </summary>
public sealed partial class PutIndexTemplateRequest : PlainRequest<PutIndexTemplateRequestParameters>
{
	public PutIndexTemplateRequest(Elastic.Clients.Elasticsearch.Serverless.Name name) : base(r => r.Required("name", name))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementPutIndexTemplate;

	protected override HttpMethod StaticHttpMethod => HttpMethod.PUT;

	internal override bool SupportsBody => true;

	internal override string OperationName => "indices.put_index_template";

	/// <summary>
	/// <para>User defined reason for creating/updating the index template</para>
	/// </summary>
	[JsonIgnore]
	public string? Cause { get => Q<string?>("cause"); set => Q("cause", value); }

	/// <summary>
	/// <para>If `true`, this request cannot replace or update existing index templates.</para>
	/// </summary>
	[JsonIgnore]
	public bool? Create { get => Q<bool?>("create"); set => Q("create", value); }

	/// <summary>
	/// <para>Period to wait for a connection to the master node.<br/>If no response is received before the timeout expires, the request fails and returns an error.</para>
	/// </summary>
	[JsonIgnore]
	public Elastic.Clients.Elasticsearch.Serverless.Duration? MasterTimeout { get => Q<Elastic.Clients.Elasticsearch.Serverless.Duration?>("master_timeout"); set => Q("master_timeout", value); }

	/// <summary>
	/// <para>This setting overrides the value of the `action.auto_create_index` cluster setting.<br/>If set to `true` in a template, then indices can be automatically created using that template even if auto-creation of indices is disabled via `actions.auto_create_index`.<br/>If set to `false`, then indices or data streams matching the template must always be explicitly created, and may never be automatically created.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("allow_auto_create")]
	public bool? AllowAutoCreate { get; set; }

	/// <summary>
	/// <para>An ordered list of component template names.<br/>Component templates are merged in the order specified, meaning that the last component template specified has the highest precedence.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("composed_of")]
	public ICollection<Elastic.Clients.Elasticsearch.Serverless.Name>? ComposedOf { get; set; }

	/// <summary>
	/// <para>If this object is included, the template is used to create data streams and their backing indices.<br/>Supports an empty object.<br/>Data streams require a matching index template with a `data_stream` object.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("data_stream")]
	public Elastic.Clients.Elasticsearch.Serverless.IndexManagement.DataStreamVisibility? DataStream { get; set; }

	/// <summary>
	/// <para>Marks this index template as deprecated. When creating or updating a non-deprecated index template<br/>that uses deprecated components, Elasticsearch will emit a deprecation warning.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("deprecated")]
	public bool? Deprecated { get; set; }

	/// <summary>
	/// <para>The configuration option ignore_missing_component_templates can be used when an index template<br/>references a component template that might not exist</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("ignore_missing_component_templates")]
	public ICollection<string>? IgnoreMissingComponentTemplates { get; set; }

	/// <summary>
	/// <para>Name of the index template to create.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("index_patterns")]
	public Elastic.Clients.Elasticsearch.Serverless.Indices? IndexPatterns { get; set; }

	/// <summary>
	/// <para>Optional user metadata about the index template.<br/>May have any contents.<br/>This map is not automatically generated by Elasticsearch.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("_meta")]
	public IDictionary<string, object>? Meta { get; set; }

	/// <summary>
	/// <para>Priority to determine index template precedence when a new data stream or index is created.<br/>The index template with the highest priority is chosen.<br/>If no priority is specified the template is treated as though it is of priority 0 (lowest priority).<br/>This number is not automatically generated by Elasticsearch.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("priority")]
	public long? Priority { get; set; }

	/// <summary>
	/// <para>Template to be applied.<br/>It may optionally include an `aliases`, `mappings`, or `settings` configuration.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("template")]
	public Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexTemplateMapping? Template { get; set; }

	/// <summary>
	/// <para>Version number used to manage index templates externally.<br/>This number is not automatically generated by Elasticsearch.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("version")]
	public long? Version { get; set; }
}

/// <summary>
/// <para>Creates or updates an index template.<br/>Index templates define settings, mappings, and aliases that can be applied automatically to new indices.</para>
/// </summary>
public sealed partial class PutIndexTemplateRequestDescriptor<TDocument> : RequestDescriptor<PutIndexTemplateRequestDescriptor<TDocument>, PutIndexTemplateRequestParameters>
{
	internal PutIndexTemplateRequestDescriptor(Action<PutIndexTemplateRequestDescriptor<TDocument>> configure) => configure.Invoke(this);

	public PutIndexTemplateRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Name name) : base(r => r.Required("name", name))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementPutIndexTemplate;

	protected override HttpMethod StaticHttpMethod => HttpMethod.PUT;

	internal override bool SupportsBody => true;

	internal override string OperationName => "indices.put_index_template";

	public PutIndexTemplateRequestDescriptor<TDocument> Cause(string? cause) => Qs("cause", cause);
	public PutIndexTemplateRequestDescriptor<TDocument> Create(bool? create = true) => Qs("create", create);
	public PutIndexTemplateRequestDescriptor<TDocument> MasterTimeout(Elastic.Clients.Elasticsearch.Serverless.Duration? masterTimeout) => Qs("master_timeout", masterTimeout);

	public PutIndexTemplateRequestDescriptor<TDocument> Name(Elastic.Clients.Elasticsearch.Serverless.Name name)
	{
		RouteValues.Required("name", name);
		return Self;
	}

	private bool? AllowAutoCreateValue { get; set; }
	private ICollection<Elastic.Clients.Elasticsearch.Serverless.Name>? ComposedOfValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.IndexManagement.DataStreamVisibility? DataStreamValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.IndexManagement.DataStreamVisibilityDescriptor DataStreamDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.DataStreamVisibilityDescriptor> DataStreamDescriptorAction { get; set; }
	private bool? DeprecatedValue { get; set; }
	private ICollection<string>? IgnoreMissingComponentTemplatesValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.Indices? IndexPatternsValue { get; set; }
	private IDictionary<string, object>? MetaValue { get; set; }
	private long? PriorityValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexTemplateMapping? TemplateValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexTemplateMappingDescriptor<TDocument> TemplateDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexTemplateMappingDescriptor<TDocument>> TemplateDescriptorAction { get; set; }
	private long? VersionValue { get; set; }

	/// <summary>
	/// <para>This setting overrides the value of the `action.auto_create_index` cluster setting.<br/>If set to `true` in a template, then indices can be automatically created using that template even if auto-creation of indices is disabled via `actions.auto_create_index`.<br/>If set to `false`, then indices or data streams matching the template must always be explicitly created, and may never be automatically created.</para>
	/// </summary>
	public PutIndexTemplateRequestDescriptor<TDocument> AllowAutoCreate(bool? allowAutoCreate = true)
	{
		AllowAutoCreateValue = allowAutoCreate;
		return Self;
	}

	/// <summary>
	/// <para>An ordered list of component template names.<br/>Component templates are merged in the order specified, meaning that the last component template specified has the highest precedence.</para>
	/// </summary>
	public PutIndexTemplateRequestDescriptor<TDocument> ComposedOf(ICollection<Elastic.Clients.Elasticsearch.Serverless.Name>? composedOf)
	{
		ComposedOfValue = composedOf;
		return Self;
	}

	/// <summary>
	/// <para>If this object is included, the template is used to create data streams and their backing indices.<br/>Supports an empty object.<br/>Data streams require a matching index template with a `data_stream` object.</para>
	/// </summary>
	public PutIndexTemplateRequestDescriptor<TDocument> DataStream(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.DataStreamVisibility? dataStream)
	{
		DataStreamDescriptor = null;
		DataStreamDescriptorAction = null;
		DataStreamValue = dataStream;
		return Self;
	}

	public PutIndexTemplateRequestDescriptor<TDocument> DataStream(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.DataStreamVisibilityDescriptor descriptor)
	{
		DataStreamValue = null;
		DataStreamDescriptorAction = null;
		DataStreamDescriptor = descriptor;
		return Self;
	}

	public PutIndexTemplateRequestDescriptor<TDocument> DataStream(Action<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.DataStreamVisibilityDescriptor> configure)
	{
		DataStreamValue = null;
		DataStreamDescriptor = null;
		DataStreamDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>Marks this index template as deprecated. When creating or updating a non-deprecated index template<br/>that uses deprecated components, Elasticsearch will emit a deprecation warning.</para>
	/// </summary>
	public PutIndexTemplateRequestDescriptor<TDocument> Deprecated(bool? deprecated = true)
	{
		DeprecatedValue = deprecated;
		return Self;
	}

	/// <summary>
	/// <para>The configuration option ignore_missing_component_templates can be used when an index template<br/>references a component template that might not exist</para>
	/// </summary>
	public PutIndexTemplateRequestDescriptor<TDocument> IgnoreMissingComponentTemplates(ICollection<string>? ignoreMissingComponentTemplates)
	{
		IgnoreMissingComponentTemplatesValue = ignoreMissingComponentTemplates;
		return Self;
	}

	/// <summary>
	/// <para>Name of the index template to create.</para>
	/// </summary>
	public PutIndexTemplateRequestDescriptor<TDocument> IndexPatterns(Elastic.Clients.Elasticsearch.Serverless.Indices? indexPatterns)
	{
		IndexPatternsValue = indexPatterns;
		return Self;
	}

	/// <summary>
	/// <para>Optional user metadata about the index template.<br/>May have any contents.<br/>This map is not automatically generated by Elasticsearch.</para>
	/// </summary>
	public PutIndexTemplateRequestDescriptor<TDocument> Meta(Func<FluentDictionary<string, object>, FluentDictionary<string, object>> selector)
	{
		MetaValue = selector?.Invoke(new FluentDictionary<string, object>());
		return Self;
	}

	/// <summary>
	/// <para>Priority to determine index template precedence when a new data stream or index is created.<br/>The index template with the highest priority is chosen.<br/>If no priority is specified the template is treated as though it is of priority 0 (lowest priority).<br/>This number is not automatically generated by Elasticsearch.</para>
	/// </summary>
	public PutIndexTemplateRequestDescriptor<TDocument> Priority(long? priority)
	{
		PriorityValue = priority;
		return Self;
	}

	/// <summary>
	/// <para>Template to be applied.<br/>It may optionally include an `aliases`, `mappings`, or `settings` configuration.</para>
	/// </summary>
	public PutIndexTemplateRequestDescriptor<TDocument> Template(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexTemplateMapping? template)
	{
		TemplateDescriptor = null;
		TemplateDescriptorAction = null;
		TemplateValue = template;
		return Self;
	}

	public PutIndexTemplateRequestDescriptor<TDocument> Template(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexTemplateMappingDescriptor<TDocument> descriptor)
	{
		TemplateValue = null;
		TemplateDescriptorAction = null;
		TemplateDescriptor = descriptor;
		return Self;
	}

	public PutIndexTemplateRequestDescriptor<TDocument> Template(Action<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexTemplateMappingDescriptor<TDocument>> configure)
	{
		TemplateValue = null;
		TemplateDescriptor = null;
		TemplateDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>Version number used to manage index templates externally.<br/>This number is not automatically generated by Elasticsearch.</para>
	/// </summary>
	public PutIndexTemplateRequestDescriptor<TDocument> Version(long? version)
	{
		VersionValue = version;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (AllowAutoCreateValue.HasValue)
		{
			writer.WritePropertyName("allow_auto_create");
			writer.WriteBooleanValue(AllowAutoCreateValue.Value);
		}

		if (ComposedOfValue is not null)
		{
			writer.WritePropertyName("composed_of");
			JsonSerializer.Serialize(writer, ComposedOfValue, options);
		}

		if (DataStreamDescriptor is not null)
		{
			writer.WritePropertyName("data_stream");
			JsonSerializer.Serialize(writer, DataStreamDescriptor, options);
		}
		else if (DataStreamDescriptorAction is not null)
		{
			writer.WritePropertyName("data_stream");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.IndexManagement.DataStreamVisibilityDescriptor(DataStreamDescriptorAction), options);
		}
		else if (DataStreamValue is not null)
		{
			writer.WritePropertyName("data_stream");
			JsonSerializer.Serialize(writer, DataStreamValue, options);
		}

		if (DeprecatedValue.HasValue)
		{
			writer.WritePropertyName("deprecated");
			writer.WriteBooleanValue(DeprecatedValue.Value);
		}

		if (IgnoreMissingComponentTemplatesValue is not null)
		{
			writer.WritePropertyName("ignore_missing_component_templates");
			JsonSerializer.Serialize(writer, IgnoreMissingComponentTemplatesValue, options);
		}

		if (IndexPatternsValue is not null)
		{
			writer.WritePropertyName("index_patterns");
			JsonSerializer.Serialize(writer, IndexPatternsValue, options);
		}

		if (MetaValue is not null)
		{
			writer.WritePropertyName("_meta");
			JsonSerializer.Serialize(writer, MetaValue, options);
		}

		if (PriorityValue.HasValue)
		{
			writer.WritePropertyName("priority");
			writer.WriteNumberValue(PriorityValue.Value);
		}

		if (TemplateDescriptor is not null)
		{
			writer.WritePropertyName("template");
			JsonSerializer.Serialize(writer, TemplateDescriptor, options);
		}
		else if (TemplateDescriptorAction is not null)
		{
			writer.WritePropertyName("template");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexTemplateMappingDescriptor<TDocument>(TemplateDescriptorAction), options);
		}
		else if (TemplateValue is not null)
		{
			writer.WritePropertyName("template");
			JsonSerializer.Serialize(writer, TemplateValue, options);
		}

		if (VersionValue.HasValue)
		{
			writer.WritePropertyName("version");
			writer.WriteNumberValue(VersionValue.Value);
		}

		writer.WriteEndObject();
	}
}

/// <summary>
/// <para>Creates or updates an index template.<br/>Index templates define settings, mappings, and aliases that can be applied automatically to new indices.</para>
/// </summary>
public sealed partial class PutIndexTemplateRequestDescriptor : RequestDescriptor<PutIndexTemplateRequestDescriptor, PutIndexTemplateRequestParameters>
{
	internal PutIndexTemplateRequestDescriptor(Action<PutIndexTemplateRequestDescriptor> configure) => configure.Invoke(this);

	public PutIndexTemplateRequestDescriptor(Elastic.Clients.Elasticsearch.Serverless.Name name) : base(r => r.Required("name", name))
	{
	}

	internal override ApiUrls ApiUrls => ApiUrlLookup.IndexManagementPutIndexTemplate;

	protected override HttpMethod StaticHttpMethod => HttpMethod.PUT;

	internal override bool SupportsBody => true;

	internal override string OperationName => "indices.put_index_template";

	public PutIndexTemplateRequestDescriptor Cause(string? cause) => Qs("cause", cause);
	public PutIndexTemplateRequestDescriptor Create(bool? create = true) => Qs("create", create);
	public PutIndexTemplateRequestDescriptor MasterTimeout(Elastic.Clients.Elasticsearch.Serverless.Duration? masterTimeout) => Qs("master_timeout", masterTimeout);

	public PutIndexTemplateRequestDescriptor Name(Elastic.Clients.Elasticsearch.Serverless.Name name)
	{
		RouteValues.Required("name", name);
		return Self;
	}

	private bool? AllowAutoCreateValue { get; set; }
	private ICollection<Elastic.Clients.Elasticsearch.Serverless.Name>? ComposedOfValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.IndexManagement.DataStreamVisibility? DataStreamValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.IndexManagement.DataStreamVisibilityDescriptor DataStreamDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.DataStreamVisibilityDescriptor> DataStreamDescriptorAction { get; set; }
	private bool? DeprecatedValue { get; set; }
	private ICollection<string>? IgnoreMissingComponentTemplatesValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.Indices? IndexPatternsValue { get; set; }
	private IDictionary<string, object>? MetaValue { get; set; }
	private long? PriorityValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexTemplateMapping? TemplateValue { get; set; }
	private Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexTemplateMappingDescriptor TemplateDescriptor { get; set; }
	private Action<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexTemplateMappingDescriptor> TemplateDescriptorAction { get; set; }
	private long? VersionValue { get; set; }

	/// <summary>
	/// <para>This setting overrides the value of the `action.auto_create_index` cluster setting.<br/>If set to `true` in a template, then indices can be automatically created using that template even if auto-creation of indices is disabled via `actions.auto_create_index`.<br/>If set to `false`, then indices or data streams matching the template must always be explicitly created, and may never be automatically created.</para>
	/// </summary>
	public PutIndexTemplateRequestDescriptor AllowAutoCreate(bool? allowAutoCreate = true)
	{
		AllowAutoCreateValue = allowAutoCreate;
		return Self;
	}

	/// <summary>
	/// <para>An ordered list of component template names.<br/>Component templates are merged in the order specified, meaning that the last component template specified has the highest precedence.</para>
	/// </summary>
	public PutIndexTemplateRequestDescriptor ComposedOf(ICollection<Elastic.Clients.Elasticsearch.Serverless.Name>? composedOf)
	{
		ComposedOfValue = composedOf;
		return Self;
	}

	/// <summary>
	/// <para>If this object is included, the template is used to create data streams and their backing indices.<br/>Supports an empty object.<br/>Data streams require a matching index template with a `data_stream` object.</para>
	/// </summary>
	public PutIndexTemplateRequestDescriptor DataStream(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.DataStreamVisibility? dataStream)
	{
		DataStreamDescriptor = null;
		DataStreamDescriptorAction = null;
		DataStreamValue = dataStream;
		return Self;
	}

	public PutIndexTemplateRequestDescriptor DataStream(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.DataStreamVisibilityDescriptor descriptor)
	{
		DataStreamValue = null;
		DataStreamDescriptorAction = null;
		DataStreamDescriptor = descriptor;
		return Self;
	}

	public PutIndexTemplateRequestDescriptor DataStream(Action<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.DataStreamVisibilityDescriptor> configure)
	{
		DataStreamValue = null;
		DataStreamDescriptor = null;
		DataStreamDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>Marks this index template as deprecated. When creating or updating a non-deprecated index template<br/>that uses deprecated components, Elasticsearch will emit a deprecation warning.</para>
	/// </summary>
	public PutIndexTemplateRequestDescriptor Deprecated(bool? deprecated = true)
	{
		DeprecatedValue = deprecated;
		return Self;
	}

	/// <summary>
	/// <para>The configuration option ignore_missing_component_templates can be used when an index template<br/>references a component template that might not exist</para>
	/// </summary>
	public PutIndexTemplateRequestDescriptor IgnoreMissingComponentTemplates(ICollection<string>? ignoreMissingComponentTemplates)
	{
		IgnoreMissingComponentTemplatesValue = ignoreMissingComponentTemplates;
		return Self;
	}

	/// <summary>
	/// <para>Name of the index template to create.</para>
	/// </summary>
	public PutIndexTemplateRequestDescriptor IndexPatterns(Elastic.Clients.Elasticsearch.Serverless.Indices? indexPatterns)
	{
		IndexPatternsValue = indexPatterns;
		return Self;
	}

	/// <summary>
	/// <para>Optional user metadata about the index template.<br/>May have any contents.<br/>This map is not automatically generated by Elasticsearch.</para>
	/// </summary>
	public PutIndexTemplateRequestDescriptor Meta(Func<FluentDictionary<string, object>, FluentDictionary<string, object>> selector)
	{
		MetaValue = selector?.Invoke(new FluentDictionary<string, object>());
		return Self;
	}

	/// <summary>
	/// <para>Priority to determine index template precedence when a new data stream or index is created.<br/>The index template with the highest priority is chosen.<br/>If no priority is specified the template is treated as though it is of priority 0 (lowest priority).<br/>This number is not automatically generated by Elasticsearch.</para>
	/// </summary>
	public PutIndexTemplateRequestDescriptor Priority(long? priority)
	{
		PriorityValue = priority;
		return Self;
	}

	/// <summary>
	/// <para>Template to be applied.<br/>It may optionally include an `aliases`, `mappings`, or `settings` configuration.</para>
	/// </summary>
	public PutIndexTemplateRequestDescriptor Template(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexTemplateMapping? template)
	{
		TemplateDescriptor = null;
		TemplateDescriptorAction = null;
		TemplateValue = template;
		return Self;
	}

	public PutIndexTemplateRequestDescriptor Template(Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexTemplateMappingDescriptor descriptor)
	{
		TemplateValue = null;
		TemplateDescriptorAction = null;
		TemplateDescriptor = descriptor;
		return Self;
	}

	public PutIndexTemplateRequestDescriptor Template(Action<Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexTemplateMappingDescriptor> configure)
	{
		TemplateValue = null;
		TemplateDescriptor = null;
		TemplateDescriptorAction = configure;
		return Self;
	}

	/// <summary>
	/// <para>Version number used to manage index templates externally.<br/>This number is not automatically generated by Elasticsearch.</para>
	/// </summary>
	public PutIndexTemplateRequestDescriptor Version(long? version)
	{
		VersionValue = version;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (AllowAutoCreateValue.HasValue)
		{
			writer.WritePropertyName("allow_auto_create");
			writer.WriteBooleanValue(AllowAutoCreateValue.Value);
		}

		if (ComposedOfValue is not null)
		{
			writer.WritePropertyName("composed_of");
			JsonSerializer.Serialize(writer, ComposedOfValue, options);
		}

		if (DataStreamDescriptor is not null)
		{
			writer.WritePropertyName("data_stream");
			JsonSerializer.Serialize(writer, DataStreamDescriptor, options);
		}
		else if (DataStreamDescriptorAction is not null)
		{
			writer.WritePropertyName("data_stream");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.IndexManagement.DataStreamVisibilityDescriptor(DataStreamDescriptorAction), options);
		}
		else if (DataStreamValue is not null)
		{
			writer.WritePropertyName("data_stream");
			JsonSerializer.Serialize(writer, DataStreamValue, options);
		}

		if (DeprecatedValue.HasValue)
		{
			writer.WritePropertyName("deprecated");
			writer.WriteBooleanValue(DeprecatedValue.Value);
		}

		if (IgnoreMissingComponentTemplatesValue is not null)
		{
			writer.WritePropertyName("ignore_missing_component_templates");
			JsonSerializer.Serialize(writer, IgnoreMissingComponentTemplatesValue, options);
		}

		if (IndexPatternsValue is not null)
		{
			writer.WritePropertyName("index_patterns");
			JsonSerializer.Serialize(writer, IndexPatternsValue, options);
		}

		if (MetaValue is not null)
		{
			writer.WritePropertyName("_meta");
			JsonSerializer.Serialize(writer, MetaValue, options);
		}

		if (PriorityValue.HasValue)
		{
			writer.WritePropertyName("priority");
			writer.WriteNumberValue(PriorityValue.Value);
		}

		if (TemplateDescriptor is not null)
		{
			writer.WritePropertyName("template");
			JsonSerializer.Serialize(writer, TemplateDescriptor, options);
		}
		else if (TemplateDescriptorAction is not null)
		{
			writer.WritePropertyName("template");
			JsonSerializer.Serialize(writer, new Elastic.Clients.Elasticsearch.Serverless.IndexManagement.IndexTemplateMappingDescriptor(TemplateDescriptorAction), options);
		}
		else if (TemplateValue is not null)
		{
			writer.WritePropertyName("template");
			JsonSerializer.Serialize(writer, TemplateValue, options);
		}

		if (VersionValue.HasValue)
		{
			writer.WritePropertyName("version");
			writer.WriteNumberValue(VersionValue.Value);
		}

		writer.WriteEndObject();
	}
}